package com.testmanager.testmananger.zyyc.interTest.constant;

import com.testmanager.testmananger.foundation.domain.enums.EnumBase;

import java.util.Arrays;

/**
 * @author hesencun
 * @date: 2021/6/30 11:21 AM
 */
public enum CaseTestResultType implements EnumBase {
    SUCCESS("成功",1),
    FAILURE("失败",2),
    SKIP("跳过",3),
    SUCCESS_PERCENTAGE_FAILURE("失败比例",4),
    STARTED("我也不知道这是啥",16);//SUCCESS = 1;  FAILURE = 2; SKIP = 3; SUCCESS_PERCENTAGE_FAILURE = 4; int STARTED= 16;

    private final String name;
    private final int value;

    CaseTestResultType(String name, int value) {
        this.name = name;
        this.value = value;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    public static CaseTestResultType getValueOf(Integer value){

        return Arrays.stream(CaseTestResultType.values())
                .filter(t->t.getValue().equals(value))
                .findFirst()
                .orElse(CaseTestResultType.SUCCESS);
    }

}
